<template>
  <el-row class="tac">
   
    <el-col :span="24">
      <el-menu
        active-text-color="#ffd04b"
        background-color="#545c64"
        class="el-menu-vertical-demo"
        text-color="#fff"
        router
        :default-active="router"
        @open="handleOpen"
        @close="handleClose"
        default-openeds
        
      >
      <el-sub-menu index="/home" >
          <template #title>
            <el-menu-item index="/kongbai"  >
          <!-- <el-icon><location /></el-icon> -->
            <span>订单管理列表({{ state.count || 0 }})</span>
        </el-menu-item>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/kongbai?id=0"  >
              <el-icon><location /></el-icon>
            <span>未采购({{ state.state0 || 0 }})</span>
            </el-menu-item>
            <el-menu-item index="/kongbai?id=1"  >
              <el-icon><location /></el-icon>
                <span>已采购({{ state.state1 || 0 }})</span>
            </el-menu-item>
            <el-menu-item index="/kongbai?id=2"  >
              <el-icon><location /></el-icon>
                <span>采购异常({{ state.state2 || 0 }})</span>
            </el-menu-item>
            <el-menu-item index="/kongbai?id=3"  >
              <el-icon><location /></el-icon>
                <span>已打单({{ state.state3 || 0 }})</span>
            </el-menu-item>
            <el-menu-item index="/kongbai?id=4"  >
              <el-icon><location /></el-icon>
                <span>已发货({{ state.state4 || 0 }})</span>
            </el-menu-item>
            <el-menu-item index="/kongbai?id=5"  >
              <el-icon><location /></el-icon>
                <span>已签收({{ state.state5 || 0 }})</span>
            </el-menu-item>
            <el-menu-item index="/kongbai?id=6"  >
              <el-icon><location /></el-icon>
                <span>签收异常({{ state.state6 || 0 }})</span>
            </el-menu-item>
            <el-menu-item index="/kongbai?id=7"  >
              <el-icon><location /></el-icon>
                <span>作废订单({{ state.state7 || 0 }})</span>
            </el-menu-item>
              </el-menu-item-group>
            </el-sub-menu>
        <!-- <el-menu-item index="/home"  >
          <el-icon><location /></el-icon>
            <span>订单管理列表</span>
        </el-menu-item> -->
       
        <el-menu-item index="/userList" :disabled="isShop">
          <el-icon><icon-menu /></el-icon>
          <span>账号管理列表</span>
        </el-menu-item>
        <el-menu-item index="/DianPuList" :disabled="isShop">
          <el-icon><icon-menu /></el-icon>
          <span>店铺管理列表</span>
        </el-menu-item>
      </el-menu>
    </el-col>
  </el-row>
</template>

<script lang="ts" setup>
import { ref ,reactive,onMounted } from 'vue'
import { ElMessage,ElMessageBox  } from 'element-plus'
import {getLogin,getOrder,getOrderimport} from '@/api/service'
import {useRouter} from 'vue-router'
const router = useRouter();
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath,'111')
  router.push(key)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const state = ref(Object({
  count:0,
  state0:0,
  state1:0,
  state2:0,
  state3:0,
  state4:0,
  state5:0,
  state6:0,
  state7:0,

}))
onMounted(()=>{
  getLoginQuery();
  getLoginQuery1();
})
const isShop = ref(false);
const getLoginQuery1 = ()=>{
  let data = {
    type:'query',
  }
  getLogin(data).then((res:any)=>{
    console.log(res)
    if(res.code==1) {
      let user = localStorage.getItem('user')
      console.log(user)
      
      for(let item of res.list) {
        if(user == item.user) {
          isShop.value = item.type == 1 ?false:true
        }
      }
      return 
    }
 
    ElMessage({
      message: res.msg,
      type: 'warning',
    })
  })
}
// 获取订单列表
const getLoginQuery = ()=>{
  // 重置
  let data = {
    type:'orderstatstatecount',
  }
  getOrder(data).then((res:any)=>{
    console.log(res)
    if(res.code==1){
      const {count,state0,state1,state2,state3,state4,state5,state6,state7} = res.data
      state.value = {count,state0,state1,state2,state3,state4,state5,state6,state7}
      console.log(state)
    }
  })
}
</script>
<style scoped>
.tac {
  height: 100%;
  background-color: #545c64;
}
</style>
